/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import { Form, Button, Badge, Select, DatePicker, Radio, Descriptions, Input, Upload, Icon, TreeSelect } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
import request from '@/utils/request';

const { TextArea } = Input;
const { Option } = Select;
const TreeNode = TreeSelect.TreeNode;
const MonthPicker =DatePicker.MonthPicker

const ButtonGroup = Button.Group;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      all_staffs:[],
      all_organizations:[],
      format:'YYYY-MM-DD',
      all_party_members:[]
    };
  }
  componentDidMount() {
    const that=this;
    request(`/all_party_members`, {
      method: 'GET',
      params:{
        type:5
      }
    }).then((response) => {
      if (response.status === 200) {
        that.setState({
          all_party_members: response.data.data,
        });
      }

    });
  }
  render() {
    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form>
          <Descriptions className={'blue-descriptions'} title={<div style={{textAlign:'center',marginTop:'10px'}}>民主评议</div>} bordered>
            <Descriptions.Item label="评议党员" span={3}>
              {getFieldDecorator('party_member_id', {
                initialValue:this.props.editRecord?this.props.editRecord.party_member.id:'',
              })(
                <Select disabled={this.props.editRecord}  style={{ width: '100%' }} allowClear={false} >
                  {
                    this.state.all_party_members.map((item, index) => {
                      return <Option key={index} value={item.id}>{item.name}</Option>;
                    })
                  }
                </Select>
              )}
            </Descriptions.Item>
            <Descriptions.Item label="评议年份" span={3}>
              {getFieldDecorator('year', {
                initialValue:this.props.editRecord? this.props.editRecordyear:moment().format('YYYY'),
              })(
                <Select>
                  <Option value={2026}>2026</Option>
                  <Option value={2025}>2025</Option>
                  <Option value={2024}>2024</Option>
                  <Option value={2023}>2023</Option>
                  <Option value="2022">2022</Option>
                  <Option value="2021">2021</Option>
                  <Option value="2020">2020</Option>
                  <Option value="2019">2019</Option>
                  <Option value="2018">2018</Option>
                </Select>
              )}
            </Descriptions.Item>
            <Descriptions.Item label="评议等级" span={3}>
              {getFieldDecorator('rating', {
                initialValue:this.props.editRecord?this.props.editRecord.amount:1,
              })(
                <Radio.Group>
                  <Radio value={1}>优秀</Radio>
                  <Radio value={2}>合格</Radio>
                  <Radio value={3}>基本合格</Radio>
                  <Radio value={4}>不合格</Radio>
                </Radio.Group>
              )}
            </Descriptions.Item>

            <Descriptions.Item label="备注" span={3}>
              {getFieldDecorator('remark', {
                initialValue:this.props.editRecord?this.props.editRecord.remark:'',
              })(
                <Input />
              )}
            </Descriptions.Item>
          </Descriptions>
        </Form>

      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
